package com.hub.entity;

import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommand;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommandDescription;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisMapper;

public class MyRedisMapper implements RedisMapper<SensorReading> {


    // 保存到 redis 的命令，存成哈希表
    public RedisCommandDescription getCommandDescription() {
        return new RedisCommandDescription(RedisCommand.HSET, "sensor_tempe");
    }


    public String getKeyFromData(SensorReading data) {
        return data.getId();
    }


    public String getValueFromData(SensorReading data) {
        return data.getTemplate().toString();
    }
}
